package homework.test2;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.lang.reflect.Method;

public class Demo {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException {
        Class clazz = Class.forName("homework.test2.Student");
        //1.获取全部公共method
        Method[] methods = clazz.getMethods();
        for (Method method : methods) {
            System.out.println(method);
        }
        System.out.println("-----------------------------------");
        //2.获取所有method
        Method[] declaredMethods = clazz.getDeclaredMethods();
        for (Method declaredMethod : declaredMethods) {
            System.out.println(declaredMethod);
        }
        System.out.println("-----------------------------------");
        //3.获取单个method
        Method method = clazz.getMethod("function1");
        System.out.println(method);
        System.out.println("-----------------------------------");
        //4.获取私有method
        Method declaredMethod = clazz.getDeclaredMethod("show");
        System.out.println(declaredMethod);
    }
}
